package com.fruit.controller.base;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.web.servlet.ModelAndView;

import com.fruit.util.ResultInfo;


/**
 * @author FH Q313596790
 * 修改时间：2015、12、11
 */
public class BaseController {
	
	protected Logger logger = LoggerFactory.getLogger(BaseController.class);

	static final long serialVersionUID = 6357869213649815390L;
	
	
	/**得到ModelAndView
	 * @return
	 */
	public ModelAndView getModelAndView(){
		return new ModelAndView();
	}
	
	public ResultInfo initResult(String state, String code, String message){
		ResultInfo ri = new ResultInfo();
		ri.setState(state);
		ri.setCode(code);
		ri.setMessage(message);
		return ri;
	}
	public ResultInfo initResult(String state, String code, String message, String url){
		ResultInfo ri = new ResultInfo();
		ri.setState(state);
		ri.setCode(code);
		ri.setMessage(message);
		ri.setUrl(url);
		return ri;
	}
	
	public void logBefore(Logger logger, String interfaceName){
		logger.info("");
		logger.info("start");
		logger.info(interfaceName);
	}
	
	public void logInfo(Logger logger, String interfaceName){
		logger.info("");
		logger.info("info");
		logger.info(interfaceName);
	}
	
	public void logWarn(Logger logger, String interfaceName){
		logger.warn("");
		logger.warn("warn");
		logger.warn(interfaceName);
	}
	
	public void logError(Logger logger, String interfaceName){
		logger.error("");
		logger.error("error");
		logger.error(interfaceName);
	}
	
	public void logAfter(Logger logger){
		logger.info("end");
		logger.info("");
	}
	
}
